function Element(symbol, name, number, mass) {
    this.symbol = symbol;
    this.name = name;
    this.number = number;
    this.mass = mass;
    if (number <= 2)  {
        this.period = 1;
        this.group = number == 1 ? number : 18;
    } else if (number <= 10) {
        this.period = 2;
        this.group = number + (number <= 4 ? -2 : 8);
    } else if (number <= 18) {
        this.period = 3;
        this.group = number + (number <= 12 ? -10 : 0);
    } else if (number <= 36) {
        this.period = 4;
        this.group = number - 18;
    } else if (number <= 54) {
        this.period = 5;
        this.group = number - 36;
    } else if (number <= 86) {
        this.period = 6;
        this.group = number + (number <= 56 ? -54 : number < 72 ? -number : -68);
    } else if (number <= 118) {
        this.period = 6;
        this.group = number + (number <= 88 ? -86 : number < 104 ? -number : -100);
    }
    this.neutrons = Math.round(mass) - number;
    this.valence = this.group - (this.group < 3 ? 0 : (this.period == 1 ? 16 : 10));
}

var s2e = {
    "?"  : new Element("", "", 0, 0),

    "H"  : new Element("H",  "Hydrogen",  1,  1.00794),
    "He" : new Element("He", "Helium",    2,  4.002602),

    "Li" : new Element("Li", "Lithium",   3,  6.941),
    "Be" : new Element("Be", "Beryllium", 4,  9.012182),
    "B"  : new Element("B",  "Boron",     5,  10.811),
    "C"  : new Element("C",  "Carbon",    6,  12.0107),
    "N"  : new Element("N",  "Nitrogen",  7,  14.0067),
    "O"  : new Element("O",  "Oxygen",    8,  15.9994),
    "F"  : new Element("F",  "Fluorine",  9,  18.9984032),
    "Ne" : new Element("Ne", "Neon",      10, 20.1797),

    "Na" : new Element("Na", "Sodium",    11, 22.98976928),
    "Mg" : new Element("Mg", "Magnesium", 12, 24.305),
    "Al" : new Element("Al", "Aluminum",  13, 26.9815386),
    "Si" : new Element("Si", "Silicon",   14, 28.0855),
    "P"  : new Element("P", "Phosphorus", 15, 30.973762),
    "S"  : new Element("S",  "Sulfur",    16, 32.065),
    "Cl" : new Element("Cl", "Chlorine",  17, 35.453),
    "Ar" : new Element("Ar", "Argon",     18, 39.948),

    "K"  : new Element("K", "Potassium", 19, 39.0983),
    "Ca" : new Element("Ca", "Calcium",  20, 40.078),
    "Sc" : new Element("Sc", "Scandium", 21, 44.955912),
    "Ti" : new Element("Ti", "Titanium", 22, 47.867),
    "V"  : new Element("V", "Vanadium", 23, 50.9415),
    "Cr" : new Element("Cr", "Chromium", 24, 51.9961),
    "Mn" : new Element("Mn", "Manganese", 25, 54.938045),
    "Fe" : new Element("Fe", "Iron", 26, 55.845),
    "Co" : new Element("Co", "Cobalt", 27, 58.933195),
    "Ni" : new Element("Ni", "Nickel", 28, 58.6934),
    "Cu" : new Element("Cu", "Copper", 29, 63.546),
    "Zn" : new Element("Zn", "Zinc", 30, 65.38),
    "Ga" : new Element("Ga", "Gallium", 31, 69.723),
    "Ge" : new Element("Ge", "Germanium", 32, 72.63),
    "As" : new Element("As", "Arsenic", 33, 74.9216),
    "Se" : new Element("Se", "Selenium", 34, 78.96),
    "Br" : new Element("Br", "Bromine",  35, 79.904),
    "Kr" : new Element("Kr", "Krypton",  36, 83.798),

    "Rb" : new Element("Rb", "Rubidium",  37, 85.467),
    "Sr" : new Element("Sr", "Strontium", 38, 87.62),
    "Y"  : new Element("Y", "Yttrium",    39, 88.90585),
    "Zr" : new Element("Zr", "Zirconium", 40, 91.224),
    "Nb" : new Element("Nb", "Niobium",   41, 92.90638),
    "Mo" : new Element("Mo", "Molybdenum", 42, 95.96),
    "Tc" : new Element("Tc", "Technetium", 43, 98),
    "Ru" : new Element("Ru", "Ruthenium", 44, 101.07),
    "Rh" : new Element("Rh", "Rhodium",   45, 102.9055),
    "Pd" : new Element("Pd", "Palladium", 46, 106.42),
    "Ag" : new Element("Ag", "Silver",    47, 107.8682),
    "Cd" : new Element("Cd", "Cadmium",   48, 112.411),
    "In" : new Element("In", "Indium",    49, 114.818),
    "Sn" : new Element("Sn", "Tin",       50, 118.71),
    "Sb" : new Element("Sb", "Antimony",  51, 121.76),
    "Te" : new Element("Te", "Tellurium", 52, 127.6),
    "I"  : new Element("I",  "Iodine",    53, 126.905),
    "Xe" : new Element("Xe", "Xenon",     54, 131.29),

    "Cs" : new Element("Cs", "Cesium",    55, 132.90),
    "Ba" : new Element("Ba", "Barium",    56, 137.33),
    "La" : new Element("La", "Lanthanum", 57, 128.90547),
    "Ce" : new Element("Ce", "Cerium",    58, 140.116),
    "Pr" : new Element("Pr", "Praseodymium", 59, 140.90765),
    "Nd" : new Element("Nd", "Neodymium", 60, 144.242),
    "Pm" : new Element("Pm", "Promethium", 61, 145),
    "Sm" : new Element("Sm", "Samarium",  62, 150.36),
    "Eu" : new Element("Eu", "Europium",  63, 151.964),
    "Gd" : new Element("Gd", "Gadolinium", 64, 157.25),
    "Tb" : new Element("Tb", "Terbium",   65, 158.92535),
    "Dy" : new Element("Dy", "Dysprosium", 66, 162.5),
    "Ho" : new Element("Ho", "Holmium",   67, 164.93032),
    "Er" : new Element("Er", "Erbium",    68, 167.259),
    "Tm" : new Element("Tm", "Thulium",   69, 168.93421),
    "Yb" : new Element("Yb", "Ytterbium", 70, 173.054),
    "Lu" : new Element("Lu", "Lutetium",  71, 174.9668),
    "Hf" : new Element("Hf", "Hafnium",   72, 178.49),
    "Ta" : new Element("Ta", "Tantalum",  73, 180.94788),
    "W"  : new Element("W", "Tungsten",   74, 183.84),
    "Re" : new Element("Re", "Rhenium",   75, 186.207),
    "Os" : new Element("Os", "Osmium",    76, 190.23),
    "Ir" : new Element("Ir", "Iridium",   77, 192.217),
    "Pt" : new Element("Pt", "Platinum",  78, 195.084),
    "Au" : new Element("Au", "Gold",      79, 196.966569),
    "Hg" : new Element("Hg", "Mercury",   80, 200.59),
    "Tl" : new Element("Tl", "Thallium",  81, 204.3833),
    "Pb" : new Element("Pb", "Lead",      82, 207.2),
    "Bi" : new Element("Bi", "Bismuth",   83, 208.9804),
    "Po" : new Element("Po", "Polonium",  84, 209),
    "At" : new Element("At", "Astatine",  85, 210),
    "Rn" : new Element("Rn", "Radon",     86, 222),

    "Fr" : new Element("Fr", "Francium",  87, 223),
    "Ra" : new Element("Ra", "Radium",    88, 226),
    "Ac" : new Element("Ac", "Actinium",  89, 227),
    "Th" : new Element("Th", "Thorium",   90, 232.03806),
    "Pa" : new Element("Pa", "Protactinium", 91, 231.03588),
    "U"  : new Element("U",  "Uranium",   92, 238.02891),
    "Np" : new Element("Np", "Neptunium", 93, 237),
    "Pu" : new Element("Pu", "Plutonium", 94, 244),
    "Am" : new Element("Am", "Americium", 95, 243),
    "Cm" : new Element("Cm", "Curium",    96, 247),
    "Bk" : new Element("Bk", "Berkelium", 97, 247),
    "Cf" : new Element("Cf", "Californium", 98, 251),
    "Es" : new Element("Es", "Einsteinium", 99, 252),
    "Fm" : new Element("Fm", "Fermium",     100, 257),
    "Md" : new Element("Md", "Mendelevium", 101, 258),
    "No" : new Element("No", "Nobelium",    102, 259),
    "Lr" : new Element("Lr", "Lawrencium",  103, 262),
    "Rf" : new Element("Rf", "Rutherfordium", 104, 267),
    "Db" : new Element("Db", "Dubnium",     105, 268),
    "Sg" : new Element("Sg", "Seaborgium",  106, 271),
    "Bh" : new Element("Bh", "Bohrium",     107, 272),
    "Hs" : new Element("Hs", "Hassium",     108, 270),
    "Mt" : new Element("Mt", "Meitnerium",  109, 276),
    "Ds" : new Element("Ds", "Darmstadium", 110, 281),
    "Rg" : new Element("Rg", "Roentgenium", 111, 280),
    "Cn" : new Element("Cn", "Copernicium", 112, 285),
    "Uut" : new Element("Uut", "Ununtrium", 113, 284),
    "Uuq" : new Element("Uuq", "Ununquadium", 114, 289),
    "Uup" : new Element("Uup", "Ununpentium", 115, 288),
    "Uuh" : new Element("Uuh", "Ununhexium", 116, 293),
    "Uus" : new Element("Uus", "Ununseptium", 117, 294),
    "Uuo" : new Element("Uuo", "Ununoctium", 118, 294)
};

function getElementByAtomicNumber(an) {
    switch (an) {
        case 1 : return s2e["H"];
        case 2 : return s2e["He"];
        case 3 : return s2e["Li"];
        case 4 : return s2e["Be"];
        case 5 : return s2e["B"];
        case 6 : return s2e["C"];
        case 7 : return s2e["N"];
        case 8 : return s2e["O"];
        case 9 : return s2e["F"];
        case 10 : return s2e["Ne"];
        case 11 : return s2e["Na"];
        case 12 : return s2e["Mg"];
        case 13 : return s2e["Al"];
        case 14 : return s2e["Si"];
        case 15 : return s2e["P"];
        case 16 : return s2e["S"];
        case 17 : return s2e["Cl"];
        case 18 : return s2e["Ar"];
        case 19 : return s2e["K"];
        case 20 : return s2e["Ca"];
        case 21 : return s2e["Sc"];
        case 22 : return s2e["Ti"];
        case 23 : return s2e["V"];
        case 24 : return s2e["Cr"];
        case 25 : return s2e["Mn"];
        case 26 : return s2e["Fe"];
        case 27 : return s2e["Co"];
        case 28 : return s2e["Ni"];
        case 29 : return s2e["Cu"];
        case 30 : return s2e["Zn"];
        case 31 : return s2e["Ga"];
        case 32 : return s2e["Ge"];
        case 33 : return s2e["As"];
        case 34 : return s2e["Se"];
        case 35 : return s2e["Br"];
        case 36 : return s2e["Kr"];
        case 37 : return s2e["Rb"];
        case 38 : return s2e["Sr"];
        case 39 : return s2e["Y"];
        case 40 : return s2e["Zr"];
        case 41 : return s2e["Nb"];
        case 42 : return s2e["Mo"];
        case 43 : return s2e["Tc"];
        case 44 : return s2e["Ru"];
        case 45 : return s2e["Rh"];
        case 46 : return s2e["Pd"];
        case 47 : return s2e["Ag"];
        case 48 : return s2e["Cd"];
        case 49 : return s2e["In"];
        case 50 : return s2e["Sn"];
        case 51 : return s2e["Sb"];
        case 52 : return s2e["Te"];
        case 53 : return s2e["I"];
        case 54 : return s2e["Xe"];
        case 55 : return s2e["Cs"];
        case 56 : return s2e["Ba"];
        case 57 : return s2e["La"];
        case 58 : return s2e["Ce"];
        case 59 : return s2e["Pr"];
        case 60 : return s2e["Nd"];
        case 61 : return s2e["Pm"];
        case 62 : return s2e["Sm"];
        case 63 : return s2e["Eu"];
        case 64 : return s2e["Gd"];
        case 65 : return s2e["Tb"];
        case 66 : return s2e["Dy"];
        case 67 : return s2e["Ho"];
        case 68 : return s2e["Er"];
        case 69 : return s2e["Tm"];
        case 70 : return s2e["Yb"];
        case 71 : return s2e["Lu"];
        case 72 : return s2e["Hf"];
        case 73 : return s2e["Ta"];
        case 74 : return s2e["W"];
        case 75 : return s2e["Re"];
        case 76 : return s2e["Os"];
        case 77 : return s2e["Ir"];
        case 78 : return s2e["Pt"];
        case 79 : return s2e["Au"];
        case 80 : return s2e["Hg"];
        case 81 : return s2e["Tl"];
        case 82 : return s2e["Pb"];
        case 83 : return s2e["Bi"];
        case 84 : return s2e["Po"];
        case 85 : return s2e["At"];
        case 86 : return s2e["Rn"];
        case 87 : return s2e["Fr"];
        case 88 : return s2e["Ra"];
        case 89 : return s2e["Ac"];
        case 90 : return s2e["Th"];
        case 91 : return s2e["Pa"];
        case 92 : return s2e["U"];
        case 93 : return s2e["Np"];
        case 94 : return s2e["Pu"];
        case 95 : return s2e["Am"];
        case 96 : return s2e["Cm"];
        case 97 : return s2e["Bk"];
        case 98 : return s2e["Cf"];
        case 99 : return s2e["Es"];
        case 100 : return s2e["Fm"];
        case 101 : return s2e["Md"];
        case 102 : return s2e["No"];
        case 103 : return s2e["Lr"];
        case 104 : return s2e["Rf"];
        case 105 : return s2e["Db"];
        case 106 : return s2e["Sg"];
        case 107 : return s2e["Bh"];
        case 108 : return s2e["Hs"];
        case 109 : return s2e["Mt"];
        case 110 : return s2e["Ds"];
        case 111 : return s2e["Rg"];
        case 112 : return s2e["Cn"];
        case 113 : return s2e["Uut"];
        case 114 : return s2e["Uuq"];
        case 115 : return s2e["Uup"];
        case 116 : return s2e["Uuh"];
        case 117 : return s2e["Uus"];
        case 118 : return s2e["Uuo"];
    }
}

var a2a = { "atomic_nuclei" : "Atomic Nuclei", "periodic_squares" : "Periodic Squares" };
